<template>
	<view class="y-y-box">
		<view class="y-list">
			<view class="y-l-item"  v-for="item in 20" :key="item.id">
				<image src="/static/wx.png"></image>
				<view class="flex1 y-l-info">
					<text class="name">199元中秋促销米分</text>
					<view class="flex_between top">
						<text>￥199.00</text>
						<view class="status" @click="yuYueTap(item)">立即预约</view>
					</view>
				</view>
			</view>
			<view class="empty_loading2">
				<image v-if="body.shoLoading" src="@/pages/groupbuy/static/loading.gif"></image>
				<view v-if="body.showEmpty">———— <text>没有更多了</text> ————</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		debounce
	} from 'lodash'
	export default {
		data() {
			return {
				body: {
					shoLoading: false, //加载中
					showEmpty: false, //没有更过了
				},
				list: [],
			}
		},
		onLoad() {
			this.inti()
		},
		onReachBottom() {
			this.getList()
		},
		methods: {
			// 预约参团
			async yuYueTap(item) {
				const m =await uni.showModal({
					title:'温馨提示',
					content:'确定预约拼团'
				})
				if(m.cancel){
					return
				}
				uni.removeStorageSync('mid')
				uni.hideLoading()
				uni.showLoading({
					title:'请稍后'
				})
				const res= await this.$axios('DateGroup/dateInfo','POST','pintuan',{},1)
				uni.hideLoading()
				if(res.data.code==200){
					const value=res.data.data
					this.$navTo(`/pages/groupbuy/createOrder?type=2&id=${value.goodsid}&pintuan_card_id=${value.pintuan_card_id}&yuyue=1`)
				}else{
					uni.showModal({
						title:'温馨提示',
						content:res.data.data
					})
				}
			},
			inti() {
				this.body = {
					shoLoading: false, //加载中
					showEmpty: false, //没有更过了
				}
				this.list = []
				this.getList()
			},
			async getList() {
				this.body.shoLoading = true;
				this.body.showEmpty = false;
				const status = this.body.status
				const res = await this.$axios('ReservationLog/details', 'POST', 'pintuan', this.body)
				this.body.shoLoading = false;
				if (status != this.body.status) {
					return
				}
				if (res.data.code == 200) {
					this.list = res.data.data.list || []
					this.body.showEmpty = this.list.length <= 0;
				}
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #fbf8fb;
	}
	.y-y-box {
		padding: 0 20rpx;

		.y-list {
			padding: 0 0 20rpx;

			.y-l-item {
				background-color: #fff;
				border-radius: 10rpx;
				padding: 20rpx;
				margin-top: 20rpx;
				display: flex;
				align-items: center;
				image{
					width: 120rpx;
					height: 120rpx;
					flex-shrink: 0;
					border-radius: 12rpx;
				}
				.y-l-info{
					padding-left: 20rpx;
				}
				.name {
					font-size: 30rpx;
					font-weight: bold;
				}
				.top {
					padding: 10rpx 0;
					display: flex;
					.status {
						padding: 0 15rpx;
						line-height: 45rpx;
						height: 45rpx;
						font-size: 24rpx;
						border-radius: 6rpx;
						background: #9A1FE8;
						color: #fff;
					}
				}

				.time {
					padding: 10rpx 0;
					font-size: 24rpx;
					color: rgba(#9A1FE8, 1);
				}
			}
		}
	}
</style>